Add search to integrations 🔍#5593
Add search to integrations 🔍#5593bramkragten merged 20 commits intohome-assistant:devfrom timmo001:search-integrations
Conversation
| `; | ||
| }) | ||
| : html` | ||
| : !this._configEntries |
There was a problem hiding this comment.
Config entries will always be defined, it is inited as an empty array.
| : ""} | ||
| ${this._filter && | ||
| !configEntriesInProgress.length && | ||
| !configEntries.length |
There was a problem hiding this comment.
&& this._configEntries.length
| (configEntries: ConfigEntry[], filter?: string): ConfigEntry[] => { | ||
| if (filter) { | ||
| const options: Fuse.FuseOptions<ConfigEntry> = { | ||
| keys: ["entry_id", "domain", "title", "source"], |
There was a problem hiding this comment.
ideally, you would be able to search for the translated integration (domain) name. I don't think the source and entry_id needs to searchable. Just title and integration name.
There was a problem hiding this comment.
I'll translate this in here then and swap out the HTML to the domain returned
| let keys: any[] = ["handler"]; | ||
| configEntriesInProgress.map( | ||
| (entry: DataEntryFlowProgress): DataEntryFlowProgress => { | ||
| keys = mergeArrays( | ||
| keys, | ||
| Object.keys(entry.context).map((key: string) => `context.${key}`) | ||
| ); | ||
| return entry; | ||
| } | ||
| ); |
There was a problem hiding this comment.
Let's restrict this to localizeConfigFlowTitle(this.hass.localize, entry) and domainToName(this.hass.localize, entry.handler) and maybe entry.handler.
|
Can we make the search bar look the same as the other config pages? |
This comment has been minimized.
This comment has been minimized.
| (configEntry: ConfigEntry) => { | ||
| return { | ||
| ...configEntry, | ||
| domain: domainToName(this.hass.localize, configEntry.domain), |
There was a problem hiding this comment.
Let's add this when we fetch the config entries and also use it in the render.
| configEntries = configEntries.filter( | ||
| (configEntry: ConfigEntry) => | ||
| configEntriesSearch.findIndex( | ||
| (ce: ConfigEntry) => ce.entry_id === configEntry.entry_id | ||
| ) !== -1 | ||
| ); |
There was a problem hiding this comment.
Also means we don't have to do this.
| filter?: string | ||
| ): DataEntryFlowProgress[] => { | ||
| if (filter) { | ||
| let configEntriedInProgressSearch: DataEntryFlowProgressSearch[] = configEntriesInProgress.map( |
There was a problem hiding this comment.
Same here, add it in the subscribe function to the configEntry objects. Make a new extended type.
There was a problem hiding this comment.
Struggling here to get translations to load after subscribe change level (line 107). Its an async function is called but even if I try to move around and await that call (this.hass.loadBackendTranslation) it still returns blank, like the translation hasn't loaded yet.
The only way I've been able to get the translation is to load it at render or filter level like it is now.. 😕
Any ideas?
Co-Authored-By: Bram Kragten <mail@bramkragten.nl>
|
Got it in a working state. Added suggestions all but |
|
Ah promises. Did attempt those but I think I was having one of those days 😄 Thanks @bramkragten! 🍻 |



Proposed change
As requested 😄
Type of change
Checklist